<template>
  <div class="">
    <header class="header">
      <div class="title">
        <img src="@/assets/images/01_11.png" alt class="img_zuo" @click="jumpReturn" />
        <div>签名</div>
      </div>
    </header>
    <div class="main">
      <div class="signature-title">检查人签名</div>
      <ul class="imgs_ul">
        <li class="signature-show" v-for="(item, index) in dataList" :key="index">
          <div class="signature-img-list">
            <img :src="item.url" alt="" class="imgs">
            <div class="del-btn" @click.stop="deleteImg(item.id)">
              <p class="del-text">×</p>
            </div>
          </div>
          <p class="signature-text">{{ item.addtime }}</p>
        </li>
      </ul>
      <div class="signature-add-box" @click="jumpSignature">
        <img src="@/assets/images/jiahao.png" alt="" class="signature-img">
        <p>添加签名</p>
      </div>
    </div>
    <div class="btn-box">
      <div class="btns" @click="jumpReturn">上一步</div>
      <div class="btns" @click="jumpList">完成</div>
    </div>
  </div>
</template>

<script>
  import terminal from '@/assets/js/terminal';
  import {Toast} from "vant";
  export default {
    data () {
      return {
        responseText: 0,
        dataList: []
      };
    },
    mounted () {
      this.responseText = Number(localStorage.getItem("responseText"))
      this.query();
    },
    destroyed() {
      setTimeout( () => {
        this.$zoom.showImagesFn.hideContainer();
      })
    },
    methods: {
      query () {
        let params = {
          noweInfoId: this.responseText,
          type: 1
        };
        this.axios.get(`${this.$global_msg.Url.host}/partroInspection/selectGenerySignature`,
          { params }).then(res => {
          if (res.data.code === 200) {
            this.dataList = res.data.rows;
          } else {
            Toast(res.data.msg || '获取数据失败,请刷新页面重试')
          }
        }).catch( e => terminal._error(e));
      },
      //  返回跳转
      jumpReturn () {
        this.$router.back();
      },
      //  删除图片
      deleteImg (id, index) {
        this.axios.get(`${this.$global_msg.Url.host}/partroInspection/delGenerySignature`,
          { params: { id } }).then(res => {
          console.log(res);
          if (res.data.code === 200) {
            this.dataList.splice(index, 1)
          } else {
            Toast(res.data.msg || '获取数据失败,请刷新页面重试')
          }
        }).catch( e => terminal._error(e));
      },
      //  跳转签名页
      jumpSignature () {
        this.$router.push({
          path: 'signature',
          query: { id: 1 }
        })
      },
      //  跳转列表页
      jumpList () {
        this.$router.go(-3);
      }
    }
  }
</script>

<style scoped>
  .header {
    z-index: 999;
    height: 1.8519rem;
    background: #007aff;
    padding-top: 0.8333rem;
    box-sizing: border-box;
    position: fixed;
    width: 100%;
    top: 0;
    font-size: 0.388888rem;
  }
  .title {
    padding: 0 0.3704rem;
    display: flex;
    align-items: center;
    color: #fff;
  }
  .title>div {
    width: 100%;
    font-size: 0.4444rem;
    text-align: center;
  }
  .img_zuo {
    width: 0.2593rem;
    height: 0.463rem;
  }
  .main {
    margin-top: 1.8519rem;
    padding: 30px 20px;
    margin-bottom: 1.91852rem;
  }
  .signature-show {
    width: 100%;
  }
  .signature-img-list {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 640px;
    position: relative;
    border: 1px solid #e5e5e5;
    border-radius: 15px;
    overflow: hidden;
  }
  .del-btn {
    z-index: 998;
    position: absolute;
    right: 0;
    top: 0;
    width: 0;
    height: 0;
    border-top: 100px solid #a0a0a0;
    border-left: 100px solid transparent;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .del-text {
    position: absolute;
    right: 10px;
    top: -90px;
    width: 30px;
    height: 30px;
    color: #ffffff;
  }
  .imgs {
    width: 62%;
    height: 163%;
    transform: rotate(-90deg);
  }
  .signature-text {
    text-align: right;
    margin-bottom: 20px;
    margin-top: 5px;
    color: #3a3a3a;
  }
  .signature-title {
    margin-bottom: 10px;
    color: #333333;
  }
  .signature-add-box {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    background-color: #eef3f7;
    padding: 200px 0;
    border-radius: 10px;
    width: 100%;
  }
  .signature-img {
    width: 162px;
    margin-bottom: 30px;
  }
  .btn-box {
    z-index: 999;
    position: fixed;
    bottom: 0;
    width: 100%;
    display: flex;
    padding: 50px 50px 100px;
    box-sizing: border-box;
    background-color: #ffffff;
  }
  .btns {
    background-color: #2b6cfe;
    color: #ffffff;
    width: 50%;
    text-align: center;
    margin: 0 5px;
    font-size: 48px;
    padding: 20px 0;
    border-radius: 15px;
  }
</style>
